<%@ page contentType="text/html; charset=UTF-8" %>
<%@ page pageEncoding="UTF-8" %>
<%@ taglib uri="/struts-tags" prefix="s" %>
<h1>System Config</h1>
<script type="text/javascript" src="${contextPath}/static/script/jquery/jquery-1.4.2.js"></script>
<script type="text/javascript">
    function update() {
        $("input:checkbox").each(function () {
            $(this).val($(this).attr("checked"));
        });
        var path = $("input[name='localFolder.name']").eq(0).val();
        if (trim(path).length == 0) {
            alert("please input required fields !!");
            return;
        }
        document.forms[0].submit();
    }

    function loadFromCache(obj) {
        var name = obj.parent().parent().find("input:eq(0)").val();
        var inputText = obj.parent().parent().find("td:eq(3) > span:eq(0)");
        $.ajax({
            type:"GET",
            url:"loadFromCache.dhtml?condition.name=" + name,
            dataType:"json",
            success:function (echo) {
                inputText.html(echo.message);
            }
        });
    }

    function loadChannels(obj) {
        var inputText = obj.parent().parent().find("td:eq(3) > span:eq(0)");
        $.ajax({
            type:"GET",
            url:"loadChannels.dhtml",
            dataType:"json",
            success:function (echo) {
                inputText.html(echo.message);
            }
        });
    }

    function loadIdentifications(obj) {
        var inputText = obj.parent().parent().find("td:eq(3) > span:eq(0)");
        $.ajax({
            type:"GET",
            url:"loadIdentifications.dhtml",
            dataType:"json",
            success:function (echo) {
                inputText.html(echo.message);
            }
        });
    }
</script>

<div class="main">
    <div class="box_side search_hotel clearfix">
        <form action="update.dhtml" method="post">
            <h1>System Variable Configuration</h1>
            <table class="table_list" cellpadding="0" cellspacing="0">
                <thead>
                <tr>
                    <th>Name</th>
                    <th>Value</th>
                    <th>Operation</th>
                    <th>From Cache</th>
                </tr>
                </thead>
                <tbody>
                <tr>
                    <td>${appendDerbyLog.name}</td>
                    <td>
                        <input type="hidden" name="appendDerbyLog.name" value="${appendDerbyLog.name}">
                        <input type="checkbox" name="appendDerbyLog.value"
                               value="${appendDerbyLog.value}"
                               <s:if test="appendDerbyLog.value=='true'">checked="checked"</s:if>/></td>
                    <td><input type="button" class="common_button" onclick="loadFromCache($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>

                <tr>
                    <td>${appendFailedAvailLogOnly.name}</td>
                    <td>
                        <input type="hidden" name="appendFailedAvailLogOnly.name"
                               value="${appendFailedAvailLogOnly.name}">

                        <input type="checkbox" name="appendFailedAvailLogOnly.value"
                               value="${appendFailedAvailLogOnly.value}"
                               <s:if test="appendFailedAvailLogOnly.value=='true'">checked="checked"</s:if>/></td>
                    <td><input type="button" class="common_button" onclick="loadFromCache($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>

                <tr>
                    <td>${occupancyCheckStrict.name}</td>
                    <td>
                        <input type="hidden" name="occupancyCheckStrict.name"
                               value="${occupancyCheckStrict.name}">

                        <input type="checkbox" name="occupancyCheckStrict.value"
                               value="${occupancyCheckStrict.value}"
                               <s:if test="occupancyCheckStrict.value=='true'">checked="checked"</s:if>/></td>
                    <td><input type="button" class="common_button" onclick="loadFromCache($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>
                <tr>
                    <td>${localFolder.name}</td>
                    <td>
                        <input type="hidden" name="localFolder.name" value="${localFolder.name}">
                        <input type="text" size="100" maxlength="255" name="localFolder.value"
                               value="${localFolder.value}"/></td>
                    <td><input type="button" class="common_button" onclick="loadFromCache($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>
                <tr>
                    <td>Channel Mapping</td>
                    <td>${channels}</td>
                    <td><input type="button" class="common_button" onclick="loadChannels($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>
                <tr>
                    <td>Provider Identification</td>
                    <td>${identifications}</td>
                    <td><input type="button" class="common_button" onclick="loadIdentifications($(this));"
                               value="LoadFromCache"></td>
                    <td><span style="color: blue;font-size: 10pt;font-weight: bolder;"></span></td>
                </tr>
                </tbody>
            </table>
            <p>

            <div>
                <input class="common_button" type="button" onclick="update();" value="Submit">
            </div>
        </form>
    </div>
</div>